package com.ssm.dao;

import com.ssm.Entity.File;
import com.ssm.Entity.Folder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface FileDAOImpl {

    @Select("select * from filee where folderId = #{folderId} and userId = #{userId}")
    List<File> findFileByFolderId(File file);


    @Insert("insert into filee (folderId, userId, fileSize, fileRealName, fileSaveName, times) values (#{folderId}, #{userId}, #{fileSize}, #{fileRealName}, #{fileSaveName}, #{times})")
    int createFile(File fille);

    @Update("update folderr set folderSize = #{folderSize} where folderId = #{folderId}")
    int updateFolderSize(Folder folder);

    @Select("select times from filee where fileSaveName = #{fileName}")
    Integer selectFileTimesByFileName(String fileName);

    @Update("update filee set times = #{times} where fileSaveName = #{fileName}")
    int updateFileTimesByFileName(@Param("fileName")String fileName, @Param("times") int times);
}
